package designpattern.mvc.v1;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Control extends View implements ActionListener {//耦合计算类和视图类，但是只负责协调数据
 Model model;//
 public Control() {
  model = new Model();
  addButton.addActionListener(this);
 }
 @Override
 public void actionPerformed(ActionEvent e) {
  model.setInput(Integer.parseInt(a.getText()),
    Integer.parseInt(b.getText()));// 协调传入的数据
  model.calculate();
  c.setText(Integer.toString(model.getOutput()));// 协调传出的数据
  repaint();
 }
}
